const { list, add, deleteRecord } = require('./data/movie-tags')

const base = '/movieserver'

module.exports = [{
  url: `${base}/movieTags`,
  type: 'get',
  response: config => {
    const { name } = config.query
    return list(name)
  }
}, {
  url: `${base}/movieTags`,
  type: 'post',
  response: config => {
    const { name } = config.body
    add({ name })
    return { success: true }
  }
}, {
  url: `${base}/movieTags/[1-9][0-9]*`,
  type: 'delete',
  response: config => {
    const id = config.url.match(/[1-9][0-9]*/)
    deleteRecord(id)
    return { success: true }
  }
}]
